package com.heima.wemedia.config;

import com.aliyun.green20220302.Client;
import com.aliyun.teaopenapi.models.Config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Data
@Configuration
@ConfigurationProperties(prefix = "aliyun.green")
public class AliYunGreenConfig {
    private String accessKeyId;
    private String accessKeySecret;
    private String regionId;
    private String endpoint;
    private Integer readTimeout;
    private Integer connectTimeout;
    private String textService; //文本审核服务
    private String imageService; //图片审核服务

    @Bean
    public Client client() throws Exception {
        Config config = new Config();
        config.setAccessKeyId(this.accessKeyId);
        config.setAccessKeySecret(this.accessKeySecret);
        //接入区域和地址请根据实际情况修改
        config.setRegionId(this.regionId);
        config.setEndpoint(this.endpoint);
        //连接时超时时间，单位毫秒（ms）。
        config.setReadTimeout(this.readTimeout);
        //读取时超时时间，单位毫秒（ms）。
        config.setConnectTimeout(this.connectTimeout);

        return new Client(config);
    }
}















